console.log('background is open')
// background.js

// 监听插件安装事件
chrome.runtime.onInstalled.addListener(() => {
  console.log('插件已安装')
})

// 监听消息传递事件
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  if (request.message === 'hello') {
    console.log('收到消息：hello')
    sendResponse({ message: 'world' })
  }
})

// 读取存储数据
chrome.storage.sync.get(['myKey'], (result) => {
  console.log('Value currently is ' + result.myKey)
})

// 写入存储数据
chrome.storage.sync.set({ myKey: 'myValue' }, () => {
  console.log('Value is set to ' + 'myValue')
})
